<template>
  <!-- vue实例外创建 -->
  <div>
    <el-container>
      <el-header>管理系统
        <div><el-dropdown :hide-on-click="false">
            <span class="el-dropdown-link">
              <img class="ahead" src="https://s21.ax1x.com/2024/12/18/pALyavV.png" alt="">
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>个人中心</el-dropdown-item>
              <el-dropdown-item>控制台</el-dropdown-item>
              <el-dropdown-item divided>退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown></div>
      </el-header>
      <el-container>
        <el-aside width="180px">
          <el-menu default-active="2" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose"
            background-color="#545c64" text-color="#fff" active-text-color="#ffd04b" router="router">
            <el-submenu :index="item.path" v-for="item in menuslist" :key="item.id + ''">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>{{ item.authName }}</span>
              </template>
              <el-menu-item-group v-for="ited in item.children" :key="ited.id">
                <el-menu-item :index="ited.path">{{ ited.authName }}</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
import axios from 'axios'
import { GetMenus } from '@/api/user'
export default {
  data() {
    return {
      menuslist: []
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    goto2() {
      this.$router.push('goto2')
    },
    async getdata() {
      let { data } = await GetMenus()
      this.menuslist = data
    }

  },
  mounted() {
    this.getdata()
  }
};
</script>
<style scoped>
.el-header {
  background-color: var(--color);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.el-aside {
  height: 91vh;
  background-color: #545c64;
  overflow: hidden;
}

.el-menu {
  overflow: hidden;
  border-right: 1px solid #545c64;
}

.ahead {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}
</style>